package com.cwd.arm.inter.util;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.cwd.arm.common.enums.BusinessTypeEnum;
import com.cwd.arm.common.enums.ProjectStatusEnum;
import com.cwd.arm.common.enums.ProjectTypeEnum;
import com.cwd.arm.common.util.DateUtil;

import java.util.Date;

/**
 * @author yan
 */
public class JxlsUtils {

    public String dateFmt(Date date) {
        if (date == null) {
            return "";
        }
        try {
            return DateUtil.dateToDateStr(date);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

    public String timeFmt(Date date) {
        if (date == null) {
            return "";
        }
        try {
            return DateUtil.dateToTimeStr(date);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

    public String booleanFmt(Boolean b) {
        if (b == null) {
            return "";
        }
        if (b) {
            return "是";
        }
        return "否";
    }

    public String projectStatusFmt(Integer projectStatus){
        if(projectStatus == null){
            return "";
        }
        return ProjectStatusEnum.getName(projectStatus);
    }

    public String projectTypeFmt(String projectType){
        if(StringUtils.isEmpty(projectType)){
            return "";
        }
        return ProjectTypeEnum.getName(projectType);
    }

    public String businessTypeFmt(String businessType){
        if(StringUtils.isEmpty(businessType)){
            return "";
        }
        return BusinessTypeEnum.getName(businessType);
    }
}
